Using the lineStarts Array to Determine Line Length
The lineStarts array is a field in the TextEdit record that contains the offset position of the first character of each line. This array has the following
boundary conditions:
• The first entry has index 0 and value 0.
• The last entry in the array has index nLines and value teLength
(hence, there are nLines + 1 entries).
• The beginning of the first line is given by lineStarts[0], and the
beginning of the second line is given by lineStarts[1]; hence, the length
of the first line is given by lineStarts[1] - lineStarts[0].
• The maximum number of entries is 16,000.
To determine the length of a line, you can use the information contained in the
lineStarts array and the nLines field. For example, if you want to determine
the length of the line n (where n = 0 for the first line), subtract its start
location ( contained in the array entry with index n) from its end location
( contained in the array with index n + 1):
lengthOfLineN = ((*myTE)->.lineStarts)[n+1] -
((*myTE)->.lineStarts)[n];
The terminating condition for this measurement is when n is equal to nLines
plus 1.
It is important not to change the information contained in the lineStarts
array.